package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.PcbaDeviceResource;
import com.sailfish.springbootdemo.service.db1.PcbaDeviceResourceService;
import com.sailfish.springbootdemo.utils.CommonUtils;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/pcbaDeviceResource")
@CrossOrigin
public class PcbaDeviceResourceController {

    @Autowired
    private PcbaDeviceResourceService pcbaDeviceResourceService;

    @PostMapping("/getAllByDeviceTypeAndSearch")
    public Result getAllByDeviceTypeAndSearch(String searchValue, Integer pcbaDeviceTypeId, Integer pcbaDeviceResourceId, Integer isTechOwn, Integer status, Integer brandId, Integer brandTypeId, Integer auditStatusBase, Integer auditStatusTech, Integer page, Integer pageSize) {
        return pcbaDeviceResourceService.getAllByDeviceTypeAndSearch(searchValue, pcbaDeviceTypeId, pcbaDeviceResourceId, isTechOwn, status, brandId, brandTypeId, auditStatusBase, auditStatusTech, page, pageSize);
    }

    @PostMapping("/getAllPcbaDeviceResource")
    public Result getAllPcbaDeviceResource() {
        return pcbaDeviceResourceService.getAllPcbaDeviceResource();
    }


    @PostMapping("/deleteById")
    public Result deleteById(Integer pcbaDeviceResourceId) {
        return pcbaDeviceResourceService.deleteById(pcbaDeviceResourceId);
    }

    @PostMapping("/addOrUpdateDeviceAndParamRelated")
    public Result addOrUpdateDeviceAndParamRelated(@RequestBody String data) {
        return pcbaDeviceResourceService.addOrUpdateDeviceAndParamRelated(data);
    }

    @PostMapping("/addOrUpdateTechAndParamRelated")
    public Result addOrUpdateTechAndParamRelated(@RequestBody String data) {
        return pcbaDeviceResourceService.addOrUpdateTechAndParamRelated(data);
    }

    @PostMapping("/judgeUnique")
    public Result judgeUnique(Integer pcbaDeviceTypeId, Integer brandId, Integer brandTypeId, String notes, Integer pcbaDeviceResourceId) {
        return pcbaDeviceResourceService.judgeUnique(pcbaDeviceTypeId, brandId, brandTypeId, notes, pcbaDeviceResourceId);
    }

    @PostMapping("/judgeUniqueByDeviceTypeAndBrandAndBrandType")
    public Result judgeUniqueByDeviceTypeAndBrandAndBrandType(Integer pcbaDeviceTypeId, Integer brandId, Integer brandTypeId, Integer pcbaDeviceResourceId) {
        return pcbaDeviceResourceService.judgeUniqueByDeviceTypeAndBrandAndBrandType(pcbaDeviceTypeId, brandId, brandTypeId, pcbaDeviceResourceId);
    }

    @PostMapping("/exportDeviceResourceAndPcbaDeviceParamTable")
    public Result exportDeviceResourceAndPcbaDeviceParamTable(@RequestBody String data) {
        return pcbaDeviceResourceService.exportDeviceResourceAndPcbaDeviceParamTable(data);
    }

    @PostMapping("/exportDeviceResourceAndPcbaDeviceParamTableOfTemplates")
    public Result exportDeviceResourceAndPcbaDeviceParamTableOfTemplates(String pcbaDeviceTypeIds) {
        return pcbaDeviceResourceService.exportDeviceResourceAndPcbaDeviceParamTableOfTemplates(pcbaDeviceTypeIds);
    }

    @PostMapping("/exportDeviceResourceAndTechDeviceParamTable")
    public Result exportDeviceResourceAndTechDeviceParamTable(@RequestBody String data) {
        return pcbaDeviceResourceService.exportDeviceResourceAndTechDeviceParamTable(data);
    }

    @PostMapping("/importPcbaDeviceResourcesExcel")
    public Result importPcbaDeviceResourcesExcel(MultipartFile file) {
        return pcbaDeviceResourceService.importPcbaDeviceResourcesExcel(file);
    }

    @PostMapping("/importPcbaDeviceResourcesExcelV2")
    public Result importPcbaDeviceResourcesExcelV2(MultipartFile file) {
        return pcbaDeviceResourceService.importPcbaDeviceResourcesExcelV2(file);
    }

    @PostMapping("/importPcbaDeviceResourcesBulkUpdateForParamAdd")
    public Result importPcbaDeviceResourcesBulkUpdateForParamAdd(MultipartFile file) {
        return pcbaDeviceResourceService.importPcbaDeviceResourcesBulkUpdateForParamAdd(file);
    }

    @PostMapping("/submitImportPcbaDeviceResourcesBulkUpdateForParamAdd")
    public Result submitImportPcbaDeviceResourcesBulkUpdateForParamAdd(@RequestBody String data) {
        return pcbaDeviceResourceService.submitImportPcbaDeviceResourcesBulkUpdateForParamAdd(data);
    }

    @PostMapping("/submitImportPcbaDeviceResourcesData")
    public Result submitImportPcbaDeviceResourcesData(@RequestBody String data) {
        return pcbaDeviceResourceService.submitImportPcbaDeviceResourcesData(data);
    }

    @PostMapping("/importTechDeviceResourcesExcel")
    public Result importTechDeviceResourcesExcel(MultipartFile file) {
        return pcbaDeviceResourceService.importTechDeviceResourcesExcel(file);
    }

    @PostMapping("/submitImportTechDeviceResourcesData")
    public Result submitImportTechDeviceResourcesData(@RequestBody String data) {
        return pcbaDeviceResourceService.submitImportTechDeviceResourcesData(data);
    }

    @PostMapping("/auditPcbaDeviceResource")
    public Result auditPcbaDeviceResource(Integer pcbaDeviceResourceId, Integer auditStatusBase, String auditRemarkBase) {
        return pcbaDeviceResourceService.auditPcbaDeviceResource(pcbaDeviceResourceId, auditStatusBase, auditRemarkBase);
    }

    @PostMapping("/auditTechDeviceResource")
    public Result auditTechDeviceResource(Integer pcbaDeviceResourceId, Integer auditStatusTech, String auditRemarkTech) {
        return pcbaDeviceResourceService.auditTechDeviceResource(pcbaDeviceResourceId, auditStatusTech, auditRemarkTech);
    }

    @PostMapping("/addResourceByExcel")
    public Result addResourceByExcel(@RequestBody String data) {
        return pcbaDeviceResourceService.addResourceByExcel(data);
    }

    @PostMapping("/coverResourceByExcel")
    public Result coverResourceByExcel(@RequestBody String data) {
        return pcbaDeviceResourceService.coverResourceByExcel(data);
    }
}
